// 模块  对api 进行统一管理
import request from "./request.js"
import mockRequest from "./mockAjax.js"

// 三级联动接口
// /api/product/getBaseCategoryList get 无参数
//发请求 : axios发请求返回的是Promise对象
export const reqCategoryList = () => {
  return request({
    url: '/product/getBaseCategoryList',
    method: 'get'
  })
}

export const reqGetBannerList = () => {
return  mockRequest({
  url:'/banner',
  method:'get'
})
}

//获取floor 数据

export  const reqFloorList = ()=>mockRequest.get('floor')

//获取收索模块的数据/api/list  请求方式 post
export const reqGetSearchInfo=(params)=>request({
  url:"list",
  method:"post",
  data:params
})

//获取产品详情
export const  reqGoodsInfo  = (skuId)=> request({
    url: `/item/${skuId}`,
    method: 'get'
  })
  
  //将产品添加到购物车中
  export const reqAddOrUpdateShopCart = (skuId,num)=>request({
    url:`/cart/addToCart/${skuId}/${num}`,
    method:"post"
  })
  
  //获取购物车列表数据接口
  
  export const reqCartList = ()=>request({
    url:'/cart/cartList' ,
    method:"get"
  })
  
  ///api/cart/addToCart/{ skuId }/{ skuNum }
  //添加商品数量
  
  export const  reqAddSkuNum = (skuId,skuNum)=>request({
    url:`/cart/addToCart/${skuId}/${skuNum}`,
    method:'post'
  })
  
//  /api/cart/deleteCart/{skuId}
// 删除购物车商品
 
 export const reqDeleteCart = (skuId) => request({
   url: `/cart/deleteCart/${skuId}`,
   method:'DELETE'
 })
 ///修改商品选中状态
///api/cart/checkCart/{skuId}/{isChecked}   get
export const reqCheckCart = (skuId,isChecked) =>request({
  url:  `/cart/checkCart/${skuId}/${isChecked}`,
  method:"get"
})

//获取验证码
///api/user/passport/sendCode/{phone}  get
export  const reqGetCode = (phone) =>request({
  url: `/user/passport/sendCode/${phone}`,
  method:'get'
})
//注册
//  /api/user/passport/register    post 

export  const reqUserRegister = (data) =>request({
  url:`/user/passport/register`,
  data,
  method:'post'
})

//登录
// /api/user/passport/login  method:post phone password

export const reqUserLogin =(data) => request({
  url:'/user/passport/login',
 data,
 method:"post"
})

//获取用户信息
///api/user/passport/auth/getUserInfo   get
export  const reqUserInfo = ()=>request({
  url:'/user/passport/auth/getUserInfo',
  method:'get'
})

//退出登录 
// /api/user/passport/logout get
export const reqLogout= ()=>request({
url:'/user/passport/logout',
method:'get'
}
)

//获取用户地址信息
// /api/user/userAddress/auth/findUserAddressList
// 获取用户地址信息
// get
export const reqAddressInfo = ()=>request({
  url:'/user/userAddress/auth/findUserAddressList',
  method:'get'
})

//获取订单交易页信息

// /api/order/auth/trade   get
export const reqTrade  =  ()=>request({
  url:'/order/auth/trade',
  method:'get'
})

//提交订单
///api/order/auth/submitOrder?tradeNo={tradeNo}
  
export const  reqSubmitOrder  =  (traderNo,data)=>request({
  url:`/order/auth/submitOrder?tradeNo=${traderNo}`,
  data,
  method:"post"
})

///api/payment/weixin/createNative/{orderId}
export const  reqPayStatus  = (orderId)=>{
  return request({
  url:`/payment/weixin/createNative/${orderId}`,
  method:'get'
})}


//获取个人中心的数据
//api/order/auth/{page}/{limit} get 
export const reqMyOrderList  =  (page,limit)=>request({
  url:`/order/auth/${page}/${limit}`,
  method:'get'
})